import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { MagicWeaponItemData } from "../MagicWeaponItemData";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { ColorConfig } from "../../../resource/ColorConfig";
import { Language } from "../../../../../extend/language/Language";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { ItemData } from "../../../resource/info/ItemData";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { BaseItem } from "../../common/BaseItem";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class MagicWeaponUpgradeItemRenderer
    
    export  class MagicWeaponUpgradeItemRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            setSize(76, 76);
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            var loc1=arg1 as MagicWeaponItemData;
            if (loc1 && loc1.itemData) 
            {
                this._name.htmlText = HTMLUtil.addColor(loc1.itemData.name, ColorConfig.instance.getItemColor(loc1.itemData.color).color);
                this._baseItem.itemData = loc1.itemData;
                if (!(loc1.name == null) && !(loc1.name == "")) 
                {
                    this.name = loc1.name;
                }
                else 
                {
                    this.name = "MagicWeaponUpgrade" + (Math.random() * 10000000).toString() + (Math.random() * 10000000).toString();
                }
            }
            else if (loc1 && !loc1.itemData) 
            {
                if (loc1.isOpen) 
                {
                    this._text.text = "";
                }
                else 
                {
                    this._text.text = Language.getString(27686);
                }
                this._name.htmlText = "";
                this._baseItem.itemData = null;
            }
            return;
        }

        public set selectItem(arg1: Boolean)
        {
            var loc1=data as MagicWeaponItemData;
            if (this._baseItem) 
            {
                if (arg1) 
                {
                    this._baseItem.filters = [FilterConst.colorFilter2];
                }
                else 
                {
                    this._baseItem.filters = [];
                }
            }
            return;
        }

        public get itemData(): ItemData
        {
            if (this._baseItem) 
            {
                return this._baseItem.itemData;
            }
            return null;
        }

        /* internal  */init(): void
        {
            var loc1=ObjCreate.createBg(0, 5, 90, 20, this, ImagesConst.FightingStrgBg);
            loc1.alpha = 0.5;
            var loc2=ObjCreate.createBitmap(ImagesConst.AchievementIconBg, 20, 32, this);
            this._text = ObjCreate.createGTextField("", 29, 39, 30, 50, this, GlobalStyle.setTextFormatLeading(GlobalStyle.textFormatWhite, 5));
            this._text.mouseEnabled = false;
            this._name = ObjCreate.createGTextField("", 0, 6, 76, 25, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormatWhite));
            this._baseItem = new BaseItem();
            this._baseItem.isShowLock = true;
            ObjCreate.setObjAttri(this._baseItem, 27, 40, 32, 32, this);
            return;
        }

        /* internal */ /* var */_name: GTextFiled;

        /* internal */ /* var */_text: GTextFiled;

        /* internal */ /* var */_baseItem: BaseItem;
    }
